package cn.lanqiao.entity;

import cn.lanqiao.pet.*;

public class Master {
    public static void main(String[] args) {
//        Cat cat = new Cat("波斯猫","白色");
//        cat.setName("小猫");
//        cat.setAge(1);
//        cat.setColor("白色");
//        cat.eat("鱼");
//        String sound =  cat.bark();
//        System.out.println(sound);
//        cat.sleep();
//        cat.play("球");
//        System.out.println(cat.getAge());


        try {
            Bird bird1 = new Bird("鹦鹉","绿色");
            bird1.setAge(10);
            new Master().feed(bird1);
        } catch (AgeException e) {
            e.printStackTrace();
        }

    }

    public void feed(Pet pet){
        System.out.println(pet.bark()); //多态
        if(pet instanceof Dog)
            pet.eat("骨头"); //不是多态
        else if(pet instanceof Cat)
            pet.eat("鱼");
        else
            pet.eat("虫子");
    }
}
